package org.iast.support;

import org.junit.Test;

import javax.crypto.NoSuchPaddingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

public class WeakHash {

    // https://i0x0fy4ibf.feishu.cn/docs/doccnSpjNTCtmhO3nOKQVSeyHtb?useNewLarklet=1#g3kW16
    // benchmark靶场弱哈希函数误报
    @Test
    public void TestRandom() throws NoSuchAlgorithmException {
        double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian();
    }

    @Test
    public void TestCrypto() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException {
        javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(
                "RSA/ECB/OAEPWithSHA-512AndMGF1Padding", "SunJCE");
        java.security.KeyPairGenerator keyGen =
                java.security.KeyPairGenerator.getInstance("RSA");
        keyGen.initialize(4096);
        java.security.PublicKey publicKey = keyGen.genKeyPair().getPublic();
        cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, publicKey);

        // java.security.MessageDigest.getInstance
    }
}
